<?php

/*

Add bud (addbud.pro.php)

*/
ob_start();
include "global.inc.php";

$check = check_length($note,255);
if ($check == 0)
{
	die(header(error("buds.php?game=$game","Your note is too long. It should only be 255 characters.")));
}

$note = smilies(badwords(strip_tags($note,"<b><i><u><a><font>")));

$budid = fetch("SELECT id,display_name FROM members2 WHERE username = '" . strtolower(ereg_replace(" ","",$buddy)) . "' AND game = '$game' LIMIT 1");

$fetch = fetch("SELECT id FROM buds2 WHERE bud_me = '$userid' AND bud_you = '$budid[id]' AND game = '$game'");
if ($fetch[id])
{
	die(header(error("buds.php?game=$game","$budid[display_name] is already on your buddy list.")));
}

if (!$budid[id])
{
	die(header(error("buds.php?game=$game","That isn't a real user.")));
}
else
{
	mysql_query("INSERT INTO buds2 VALUES ('','$userid','$budid[id]','$note')");
	systemmessage("$game", "buds.php?bud=$username&game=$game","$budid[id]","$display_name has added you to their buddy list.");
	die(header(error("buds.php?game=$game","$budid[display_name] has been added to your buddy list.")));
}

?>